package com.design.pattern.behavior.strategy.pay;

import java.util.HashMap;
import java.util.Map;

public class PayStrategy {
    public static final String JD_PAY = "JdPay";
    public static final String AL_PAY = "AliPay";
    public static final String WECHAT_PAY = "WechatPay";
    public static final String UNION = "UnionPay";
    public static final String DEFAULT = AL_PAY;

    private static Map<String, Payment> strategy = new HashMap<>();

    static {
        strategy.put(AL_PAY, new AliPay());
        strategy.put(JD_PAY, new JDPay());
        strategy.put(WECHAT_PAY, new WechatPay());
        strategy.put(UNION, new UnionPay());
    }


    public static Payment get(String payKey) {
        if(!strategy.containsKey(payKey)){
            return strategy.get(DEFAULT);
        }
        return strategy.get(payKey);
    }
}
